Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for OIDC session management error status #613

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

divid3byzero
Copy link

Closes/fixes #611

Checklist

  • This PR makes changes to the public API
  • I have included links for closing relevant issue numbers

@divid3byzero divid3byzero changed the title - Add support for OIDC session management error status Add support for OIDC session management error status Jul 8, 2022
@pamapa
Copy link
Member

pamapa commented Jul 11, 2022

_raiseUserSessionError is never called. What is the difference to _userSessionChanged. Why can't you use that one?

@divid3byzero
Copy link
Author

You are right, sorry, I didn't commit everything. I messed up my local development and forgot a few things in the commit after fixing it. I've committed the missing code.

Actually there are use cases when clients want to react to the error status. And as that is something different than the changed status I (and everyone else that wants to react differently to the two statuses) can't use userSessionChanged.

@@ -52,9 +54,13 @@ export class CheckSessionIFrame {
) {
if (e.data === "error") {
this._logger.error("error message from check session op iframe");
if (this._stopOnError) {
if (this._stopOnError && !this.propagateUserSessionError) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if _stopOnError is true i really would expect that this.stop() should be called. You need to rearrange your code changes

// catch to suppress errors since we're in non-promise callback
logger.error("Error from getCheckSessionIframe:", err instanceof Error ? err.message : err);
}
};

private doUserSessionErrorPropagation(): boolean {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doUserSessionErrorPropagation is only called once -> not really needed, instead add there e.g. a variable

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a matter of preference, but yes, I will introduce a variable.

@@ -55,6 +57,10 @@ export class CheckSessionIFrame {
if (this._stopOnError) {
this.stop();
}

if (this.propagateUserSessionError) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we could combine propagateUserSessionError and userSessionErrorCallback: Make userSessionErrorCallback optional, if defined call it if not not. Then propagateUserSessionError is not needed inside this class...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually the way I implemented it is the same pattern as the _callback is called after the changed status is triggered. By using the propagateUserSessionError flag it is made optional. If you'd rather like that the existence of the userSessionErrorCallback is checked to trigger that callback I would have to allow for a function to be defined in the settings object which, of course, would be possible but would break with the way that a client can attach to e.g. the changed status.

@codecov
Copy link

codecov bot commented Jul 14, 2022

Codecov Report

Merging #613 (40fb449) into main (809da48) will decrease coverage by 0.20%.
The diff coverage is 42.85%.

@@            Coverage Diff             @@
##             main     #613      +/-   ##
==========================================
- Coverage   76.91%   76.71%   -0.21%     
==========================================
  Files          44       44              
  Lines        1590     1602      +12     
  Branches      299      301       +2     
==========================================
+ Hits         1223     1229       +6     
- Misses        336      342       +6     
  Partials       31       31              
Flag Coverage Δ
unittests 76.71% <42.85%> (-0.21%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/CheckSessionIFrame.ts 3.63% <0.00%> (-0.29%) ⬇️
src/SessionMonitor.ts 14.44% <0.00%> (-0.33%) ⬇️
src/UserManagerEvents.ts 70.27% <100.00%> (+3.60%) ⬆️
src/UserManagerSettings.ts 98.30% <100.00%> (+0.05%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 809da48...40fb449. Read the comment docs.

@phlegx
Copy link

phlegx commented Mar 6, 2024

Nice work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OIDC session management error status not supported
4 participants